package 面试.HashMap遍历;

import java.util.HashMap;
import java.util.Map;

public class Demo01 {
    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<>();
        map.put(1,"张三");
        map.put(2,"李四");
/*        Set<Map.Entry<Integer,String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }*/

/*        Iterator<Integer> keys = map.keySet().iterator();
        while (keys.hasNext()){
            Integer key = keys.next();
            System.out.println(key + "" + map.get(key));
        }*/

 /*       Iterator<Map.Entry<Integer, String>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Integer, String> next = iterator.next();
            System.out.println(next.getKey() + "" + next.getValue());
        }*/

        for (Integer integer : map.keySet()) {
            System.out.println(integer);
        }

        for (String value : map.values()) {
            System.out.println(value);
        }

    }
}
